********************************************************************************
*				                 risk aversion	       						   *
********************************************************************************
*Create Barsky risk aversion groups within a single variable
/* Using the procedure and classificaiton from Barsky et al., the risk
aversion variables below categorize respondents into risk aversion groups
ranging from 1 to 4, with 1 being the most risk averse and 4 the least. A vector
variable with each classification is created below for simplicity.
Risk aversion year questions: 93, 02, 04, 06. 

Generate a risk aversion variable based only upon the 1993 score, for control
1993 is the earliest year that the risk aversion questions were implemented
so it is calculated a separate time for a baseline control. 
*/

bysort caseid: gen riskaverse1 = (jobrisk1q==0 & jobrisk3q==0 & jobrisk2q==. & year==1993)
replace riskaverse1 = . if missing(jobrisk1q)
bysort caseid: gen riskaverse2 = (jobrisk1q==0 & jobrisk3q==1 & jobrisk2q==. & year==1993)
replace riskaverse2 = . if missing(jobrisk1q)
bysort caseid: gen riskaverse3 = (jobrisk1q==1 & jobrisk2q==0 & jobrisk3q==. & year==1993)
replace riskaverse3 = . if missing(jobrisk1q)
bysort caseid: gen riskaverse4 = (jobrisk1q==1 & jobrisk2q==1 & jobrisk3q==. & year==1993)
replace riskaverse4 = . if missing(jobrisk1q)

gen riskaversion93=.
replace riskaversion93=1 if riskaverse1==1
replace riskaversion93=2 if riskaverse2==1
replace riskaversion93=3 if riskaverse3==1
replace riskaversion93=4 if riskaverse4==1
drop riskaverse*

*Carry it forward or backwards
bysort caseid: egen riskaversion2=max(riskaversion93)
drop riskaversion93
rename riskaversion2 rt93

label var rt "imputed risk tolerance, 1993 question"

gen risktolerant = rt93==1 if rt93!=.
label var risktolerant "Risk tolerant, 1993 question"

//////////////////////////////
*middle risk aversion group to follow the Danish People
///////////////////////////////////
gen riskaverse=(rt93==3 |rt93==2) if !mi(rt93)
label var riskaverse "Middle Risk Aversion, 1993 question"
